<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;
use App\Http\Services\MsgServices;

class CommandKeepAliveChat extends Command
{
    protected $signature = 'CommandKeepAliveChat';

    protected $description = '保活聊天室';

    public function __construct()
    {
        parent::__construct();
    }

    public function handle()
    {
        $msg_service = new MsgServices();

        do {
            if(!$msg_service->query_chat_room()) {
                if(!$msg_service->create_chat_room()) exit(1);
                if(!$msg_service->join_chat_room()) exit(2);
            }
            $msg_service->keep_alive_chat_room();
        } while (false);
    }

}